package com.fh.shop.api.mq.producer;

import com.alibaba.fastjson.JSON;
import com.fh.shop.config.MQConstant;
import com.fh.shop.message.MailMessage;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;


@Component
public class MailProducer {

    @Autowired
    private RabbitTemplate rabbitTemplate;

    public void mailProduce(MailMessage mailMessage){
        String mailJson = JSON.toJSONString(mailMessage);
        rabbitTemplate.convertAndSend(MQConstant.mailDirect.EX,MQConstant.mailDirect.ROUTE_KEY,mailJson);
    }
}
